package com.google.coffeeshop.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "receipt_note")
public class ReceiptNoteDTO implements Serializable {
private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name="id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@Column(name="code", nullable=false,unique =true)
	private String code;
	@Column(name="amount")
	private Long amount;
	@Column(name="receipt_date")
	private Date receiptDate;
	@Column(name="description")
	String description;
	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, mappedBy = "receiptNote")
	private List<ReceiptNoteLineDTO> receiptNoteLines;
	
	@Override
	public String toString() {
		return String.format("id=%d, code='%s'", id, code);
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getAmount() {
		return amount;
	}
	public void setAmount(Long amount) {
		this.amount = amount;
	}
	public Date getReceiptDate() {
		return receiptDate;
	}
	public void setReceiptDate(Date receiptDate) {
		this.receiptDate = receiptDate;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public List<ReceiptNoteLineDTO> getReceiptNoteLines() {
		if (receiptNoteLines == null) {
			receiptNoteLines = new ArrayList<ReceiptNoteLineDTO>();
		}
		return receiptNoteLines;
	}
	public void setReceiptNoteLines(List<ReceiptNoteLineDTO> receiptNoteLines) {
		this.receiptNoteLines = receiptNoteLines;
	}
	
}
